//
//  MutipTableViewController.m
//  Select
//
//  Created by dihuijun on 17/3/16.
//  Copyright © 2017年 Cycle. All rights reserved.
//

#import "MutipTableViewController.h"
#import "MutipChooseView.h"
@interface MutipTableViewController ()
/**   datasource   */
@property (nonatomic, strong) NSMutableArray *datasource;


/**   MutipTableChooseView   */
@property (nonatomic, strong) MutipChooseView *mutipChooseView;
@end

@implementation MutipTableViewController
/**   懒加载数据   */
- (NSMutableArray *)datasource{
    if(!_datasource){
        _datasource = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5", nil];
    }
    return _datasource;
}
/**   多选   */
- (MutipChooseView *)mutipChooseView{
    if(!_mutipChooseView){
        _mutipChooseView = [MutipChooseView shareMutipTableViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.frame.size.height) HeaderTitle:@"全选"];
        
        //数据源
        _mutipChooseView.datasource = self.datasource;
        //选中内容
        _mutipChooseView.blockMore = ^(NSString *content,NSMutableArray *chooseArray){
            NSLog(@"\n 数据content:%@ \n该content下的全部内容\n:%@",content,chooseArray);
        };
        
        
        
    }
    return _mutipChooseView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"tableView多选";
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"addDatasource" style:UIBarButtonItemStyleDone target:self action:@selector(Click)];
    
    
    [self.view addSubview:self.mutipChooseView];
}
- (void)Click{
    NSUInteger currentCount = self.datasource.count;
    
    for (int i=0;i<=10; i++) {
        [self.datasource addObject:[NSString stringWithFormat:@"%lu",currentCount+i]];
    }
    self.mutipChooseView.datasource = self.datasource;
    [self.mutipChooseView reloadData];
}

@end
